package cn.stylefeng.guns.modular.recy.warpper;

import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.guns.modular.recy.utils.DictUtils;
import cn.stylefeng.guns.modular.recy.utils.EntityBind;
import cn.stylefeng.guns.modular.recy.vo.UserBinVO;
import cn.stylefeng.guns.modular.system.entity.Dict;
import cn.stylefeng.roses.core.base.warpper.*;
import java.util.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.*;
import cn.stylefeng.roses.kernel.model.page.*;
import cn.hutool.core.map.*;
import cn.stylefeng.guns.core.common.constant.factory.*;
import org.apache.commons.lang3.*;
import cn.stylefeng.guns.modular.recy.entity.*;
import org.apache.http.util.EntityUtils;

import javax.swing.text.html.parser.Entity;

public class WechatUserWrapper extends BaseControllerWrapper
{
    public WechatUserWrapper(final Map<String, Object> single) {
        super((Map)single);
    }
    
    public WechatUserWrapper(final List<Map<String, Object>> multi) {
        super((List)multi);
    }
    
    public WechatUserWrapper(final Page<Map<String, Object>> page) {
        super((Page)page);
    }
    
    public WechatUserWrapper(final PageResult<Map<String, Object>> pageResult) {
        super((PageResult)pageResult);
    }
    
    protected void wrapTheMap(final Map<String, Object> map) {
        final Long userId = MapUtil.getLong((Map)map, "userId");
        if (userId != null) {
            String userNameById = ConstantFactory.me().getUserNameById(userId);
            //final WechatUser wechatUser = ConstantFactory.me().getWechatUserById(userId);
            //final String name = (String)StringUtils.firstNonBlank((CharSequence[])new String[] { wechatUser.getRealName(), wechatUser.getWechatNickName(), wechatUser.getUserNo() + "" });
            map.put("userId", userNameById);
        }
        else {
            map.put("userId", "--");
        }
        List<UserBin> userBinList = (List<UserBin>)map.get("userBinList");
        if(ObjectUtil.length(userBinList)>0){
            String userBins = "";
            for(UserBin userBin:userBinList){
                UserBinVO bind = EntityBind.bind(userBin, UserBinVO.class);
                userBins+=bind.getWasteTypeIdModel().getTypeName()+"："+userBin.getCardNo()+"；";
            }
            map.put("userBins",userBins);
        }else{
            map.put("userBins","未绑定回收桶");
        }
    }
}
